package ucl.cs.stockbroker.common;

import java.rmi.RemoteException;
import java.util.Map;

/**
 * StockBroker Account Interface Class.
 * @author  Min Park, Saniul Ahmed, Kamil Olesiejuk
 * @version 1.0
 */

public interface StockBrokerAccount extends java.rmi.Remote {

	/**
	 * Allows to buy stock given a valid PIN, a company symbol and the quantity.
	 * 
	 * @param pin : String - account PIN
	 * @param company : String - symbol of the company to buy stock of
	 * @param units : String - quantity of stock to buy
	 * @throws RemoteException - on remote communicatin errors
	 * @throws WrongPINException - on invalid PIN
	 * @throws NotEnoughMoneyException - on insufficient money
	 * @throws NoSuchCompanyException - on non-existent company symbol
	 */
	void buyStock(String pin, String company, int units)
			throws RemoteException, WrongPINException, NotEnoughMoneyException,
			NoSuchCompanyException;

	/**
	 * Returns the account number.
	 * 
	 * @return account number : int - the number of the account
	 * @throws RemoteException - on remote communication errors
	 */
	int getAccountNumber() throws RemoteException;

	/**
	 * Returns the account balance in pence.
	 * 
	 * @return balance : double - the balance in pence
	 * @throws RemoteException - on remote communication errors
	 */
	double getBalance() throws RemoteException;
	
	/**
	 * Returns the potential account balance on selling all the stock at current price.
	 * 
	 * @return value : double - the potential value of the account.
	 * @throws RemoteException - on remote communication errors
	 */
	double calculateAccountValue() throws RemoteException;

	/**
	 * Returns a StockAccountInfo object with information about the account like name, number,
	 * balance, owned stock. [no PIN passed]
	 * 
	 * @return StockAccountInfo object
	 * @throws RemoteException - on remote communication errors
	 */
	StockBrokerAccountInfo getDescription() throws RemoteException;

	/**
	 * Returns the account name.
	 * 
	 * @return account name : String - account name
	 * @throws RemoteException
	 */
	String getName() throws RemoteException;

	/**
	 * Returns a Map<String, Integer> containing the company symbol as String in the key field
	 * and the quantity owned of the company corresponding to that symbol.
	 * 
	 * @return owned stock : Map<Integer,String> - information on owned stock
	 * @throws RemoteException - on remote communication errors.
	 */
	Map<String, Integer> getOwnedStock() throws RemoteException;

	/**
	 * Allows to check the PIN.
	 * 
	 * @param pin : String - PIN to be checked
	 * @return isValid : boolean - is the pin valid
	 * @throws RemoteException - on remote communication errors
	 */
	boolean isPINValid(String pin) throws RemoteException;

	/**
	 * Allows selling all owned stock of one company providing a valid PIN and company symbol.
	 *  
	 * @param pin : String - PIN
	 * @param company : String - company symbol
	 * @throws RemoteException - on remote communication errors
	 * @throws WrongPINException - on invalid PIN
	 * @throws NoSuchCompanyException - on invalid company symbol
	 * @throws NotEnoughStockException - on insufficient stock [does not happen]
	 */
	void sellStock(String pin, String company) throws RemoteException,
			WrongPINException, NoSuchCompanyException, NotEnoughStockException;

	/**
	 * Allows selling owned stock of one company providing a valid PIN, valid company symbol,
	 * and a quantity.
	 *  
	 * @param pin : String - PIN
	 * @param company : String - company symbol
	 * @param units : int - the quantity of the stock to sell
	 * @throws RemoteException - on remote communication errors
	 * @throws WrongPINException - on invalid PIN
	 * @throws NoSuchCompanyException - on invalid company symbol
	 * @throws NotEnoughStockException - on insufficient stock
	 */
	void sellStock(String pin, String company, int units)
			throws RemoteException, WrongPINException, NoSuchCompanyException,
			NotEnoughStockException;
}
